/*
 * Copyright (c) 2011 Team A CS2340. All rights reserved.
 */

package edu.gatech.teama.doctorsoffice.client.presenter;

import edu.gatech.teama.doctorsoffice.client.view.*; // $codepro.audit.disable importStyle
import edu.gatech.teama.doctorsoffice.model.*; // $codepro.audit.disable importStyle

/**DoctorNurseMainPresenter.java
 * @author Bruce Zhang
 * @version 1.0
 */
public class DoctorNurseMainPresenter { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString
	/**
	 * server connection  
	 */	 
	private ServerConnection sc;

	/**
	 * logged User 
	 */
	private User loggedUser;
	
	/**
	 * Doctor Nurse Main Presenter constructor
	 */
	public DoctorNurseMainPresenter() {
		sc = ServerConnection.getInstance();
		loggedUser=sc.getLoggedInUser();
	}

	/**
	 * Doctor Nurse Main Presenter constructor taking in user
	 * @param user
	 * for testcase purpose
	 */
	public DoctorNurseMainPresenter(User user) {
		loggedUser=user;
	}

	/**
	 * @return is the user a doctor or nurse
	 */
	public boolean isDoctor() {
		if(loggedUser == null) {
			return false;
		}
		
		return (loggedUser instanceof Doctor);
	}
	
	/**
	 * @return the loged in user
	 */
	public User getLoggedUser() {
		return loggedUser;
	}
	
	/**
	 * @param u
	 * set new logged in user
	 */
	public void setLoggedUser(User u) {
		loggedUser=u;
	}

	/**
	 * change frame to userlookup
	 */
	public void searchPatient() {
		MainWindow.setPanel(new UserLookupPanel());
	}

	/**
	 * change frame to userlook up
	 * 
	 */
	public void addPatient() {
		MainWindow.setPanel(new UserLookupPanel());
		
	}

	/**
	 * change frame to appoint request panel
	 */
	public void viewAppointmentCalender() {
		MainWindow.setPanel(new AppointmentRequestPanel());
		
	}

	/**
	 * change frame to treatmentrecordpanel
	 */
	public void createTreatmentRecord() { // $codepro.audit.disable emptyMethod
		//MainWindow.setPanel(new TreatmentRecordPanel());
		
	}

	/**
	 * change frame to patientinstructionpanel
	 */
	public void createDoctorOrders() {  // $codepro.audit.disable emptyMethod
		//MainWindow.setPanel(new PatientInstructionsPanel());
		
	}

	/**
	 * log out   
	 */
	public void logOut() {
		setLoggedUser(null);
		sc.disconnect();
		MainWindow.setPanel(new LoginPanel());
	}
}
